<?
//include "./Lib/DBMySql.inc";
//include "./Lib/Common.php";
//include "./Entities/usersObj.php";
//include "./DAL/usersDAL.php";
/*
$mainDB = NewDB(DATABASE_HOST, DATABASE_NAME , DATABASE_USER, DATABASE_PASSWORD);

$user =  new usersObj();

$testTypes = array("1"=>"Insert", "2"=>"Load", "3"=>"Update", "4"=>"GetList", "5"=>"RowCount", "6"=>"Delete", 
	"7"=>"Exist", "8"=>"ComboBox", "9"=>"PushData", "10"=>"PopData");
if (!isset($id)) $id = 0;
if ($test==$testTypes["1"]) {
	//-----------------------------------------------------------------------------------------------------------------
	// ---- Insert Code -----------------------------------------------------------------------------------------------
	$user1 = new usersObj("", "", "");
	usersDAL::Pop($user1);
	if (usersDAL::Insert($mainDB, $user1, $error)) {
		ShowObject($user1, "Insert successful");
	}
	else 
		echo "Insert unsuccessful. $error";
	
	print_r($user1);
}
if ($test==$testTypes["2"]) {
	//-----------------------------------------------------------------------------------------------------------------
	// ---- Load information ------------------------------------------------------------------------------------------
	$user2 = usersDAL::Load($mainDB, $txtID, $error);
	if ($user2!=null) {
		ShowObject($user2, "Loaded data");
		usersDAL::Push($user2);
	}
	else {
		usersDAL::Push(new usersObj("","",""));
		echo "Data not found.";
	}
	
}
if ($test==$testTypes["3"]) {
	//-----------------------------------------------------------------------------------------------------------------
	// ---- Update information ----------------------------------------------------------------------------------------
	$user3 = usersDAL::Load($mainDB, $txtID, $error);
	if ($user3!=null) {
		usersDAL::Pop($user3);
		if (usersDAL::Update($mainDB, $user3, $error))
			ShowObject($user3, "Update successful");
		else 
			echo "Invalid Update function. $error";
		
	} else {
		echo "Data not found.";
	}
}
if ($test==$testTypes["4"]) {
	//-----------------------------------------------------------------------------------------------------------------
	// ---- Get list data ---------------------------------------------------------------------------------------------
	$returnData = usersDAL::GetList($mainDB, "", "", "", $errorMsg);
	if ($errorMsg=="") {
		echo "Getlist is successful.";
	} else {
		echo "Invalid GetList function. $error";
	}
	//print_r($returnData);
	for ($i=0; $i<count($returnData); $i++) {
		$dataRow = $returnData[$i];
		echo "<br>Row ".($i+1).": UserID->".$dataRow->UserID." - Username->".$dataRow->Username." - Password->".$dataRow->Password;
	}
}
if ($test==$testTypes["5"]) {
	//-----------------------------------------------------------------------------------------------------------------
	// ---- Get rowcount ----------------------------------------------------------------------------------------------
	$rowCount = RowCount($mainDB,  usersObj::TableName(), "", $errorMsg);
	if ($errorMsg=="") {
		echo "Get rowcount is successful.";
	} else {
		echo "Invalid GetList function. $error";
	}
	echo $rowCount;
}
if ($test==$testTypes["6"]) {
	//-----------------------------------------------------------------------------------------------------------------
	// ---- Delete function -------------------------------------------------------------------------------------------
	//$usersDAL = new usersDAL();
	if (usersDAL::Pure($mainDB, usersObj::UserIDFieldName()."=$txtID", $errorMsg))
		echo "Delete is successful.";
	else 
		echo "Invalid Delete function. $error";
}
if ($test==$testTypes["7"]) {
	//-----------------------------------------------------------------------------------------------------------------
	// ---- IsExist function ------------------------------------------------------------------------------------------
	$exist = usersDAL::IsExist($mainDB,  usersObj::UserIDFieldName()."=$txtID");
	
	if ($exist) 
		echo "Record is exist.";
	 else 
		echo "Record is not exist.";
	
}
if ($test==$testTypes["8"]) {
	//-----------------------------------------------------------------------------------------------------------------
	// ---- Get rowcount ----------------------------------------------------------------------------------------------
	echo GetComboBox($mainDB, usersObj::TableName(), "", "", "userOpt", "UserID", "Username", "Select one", "0", $defaultVAL, "");
}
if ($test==$testTypes["9"]) {
	//-----------------------------------------------------------------------------------------------------------------
	// ---- Get data and push to variables ----------------------------------------------------------------------------
	$user2 = usersDAL::Load($mainDB, $txtID, $error);
	if ($user2!=null) {
		usersDAL::Push($user2);
		echo "UserID: $UserID - Username: $Username - Password: $Password";
	}
	else 
		echo "Data not found.";
}
if ($test==$testTypes["10"]) {
	//-----------------------------------------------------------------------------------------------------------------
	// ---- Get data and push to variables ----------------------------------------------------------------------------
	$user2 = usersDAL::Load($mainDB, $txtID, $error);
	if ($user2!=null) {
		ShowObject($user2, "Loaded data");
		$UserID = "123"; $Username = "mmmm"; $Password = "aaa";
		usersDAL::Pop($user2);
		ShowObject($user2, "Set new data");
	}
	else 
		echo "Data not found.";
}
echo GetComboBoxFromVars($UserTypes, "UserType", "", "", $default, "");

class a {
	const bb = "GGGG";
}
echo "AAA";
echo a::bb;
*/
/*
// Test Time Zone
echo "Here";
$a = new DateTimeZone("America/Los_Angeles");
echo "Out1";
$uTimeObj= new dateTime("now",$a);
echo "Out2";
$uZoneCode=substr($uTimeObj->format("Y-m-d H:i:s O"),20);
print_r($uZoneCode);
*/
//echo md5("password");
/*
if (ini_get("register_globals")==null) echo 123;

//echo "<pre>";
//print_r($_FILES);
//echo "</pre>";
class A
{
	var $a;
	var $b;
	var $joinfields;
}
$a = new A();
$a->a = 1;
$a->b = 2;
$a->joinfields["table.name"] = 3;

echo "<pre>";
print_r($a);
echo "</pre>";
*/
include "./Lib/DBMySql.inc";
include "./Lib/Common.php";
include "./Entities/categorieschildObj.php";
include "./DAL/categorieschildDAL.php";
$mainDB = NewDB(DATABASE_HOST, DATABASE_NAME , DATABASE_USER, DATABASE_PASSWORD);
$categorieschild = categorieschildDAL::GetList($mainDB, "", "", "", $pageError, array('categories'), array('categorieschild.cateid=tbl_categories.id'), array('catecode'));
print_r($categorieschild);
?>
